const mysql=require('mysql');
//创建连接对象
const connection=mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'Zly13579',
    port:3306,
    database:'myblog'
});
//开始连接
connection.connect();
const sql='select * from blogs';
connection.query(sql,(err,result)=>{
    if(err){
        //console.log(err);
        console.error(err);
        return;
    }
    console.log(result);
})
//关闭连接
connection.end();